package com.adee.design.structure.proxy.staticproxy;

// 静态代理指编译期间实现代理，缺点需要多少个代理类就必须手动编写多少个代理类
public class Test {
    public static void main(String[] args) {
        Zhangsan zs = new Zhangsan();
        Speaker s = new ZhangsanLawyer(zs);
        s.speak();
    }
}

interface Speaker {
    void speak();
}

class Zhangsan implements Speaker {
    @Override
    public void speak() {
        System.out.println("Zhangsan被老婆打了");
    }
}

class ZhangsanLawyer implements Speaker {
    private Zhangsan zhangsan;
    public ZhangsanLawyer(Zhangsan zhangsan) {
        this.zhangsan = zhangsan;
    }
    @Override
    public void speak() {
        System.out.println("张三律师引用法律条文");
        zhangsan.speak();
        System.out.println("张三律师得出结论：打人是不对的");
    }
}


